import java.sql.Connection;
import java.sql.DriverManager;
import java.sql.SQLException;

public class DataBaseManager {

	public static String fichierConnexion ="db.ini";
	private static  DataBaseManager instance;
	private  String driver ;
	private  String url ;
	private  String user ;
	private  String password ;
	private  Connection connexion;

	public DataBaseManager() {
		this.connexion = null;
		this.driver =  "com.mysql.jdbc.Driver";
		this.url="jdbc:mysql://localhost/Project";
		this.user =  "root";
		this.password = "";
		try
		{
			Class.forName(driver).newInstance();
			connexion = DriverManager.getConnection(url, user, password);
			System.out.println("Database Manager init : OK");

		} catch (Exception e) {System.out.println(e);}
	}

	public  static  DataBaseManager getInstance( ) 
	{
		if (instance == null) 
			instance = new DataBaseManager();
		return instance;
	}

	public Connection getConnexion() 
	{return connexion;}

	public static void  deleteInstance( ) 
	{
		if (instance != null) 
			try { instance.connexion.close();} 
		catch (SQLException e) {System.out.println(e);}
	}

}
